package com.itcast.activiti.controller;


import cn.itcast.ic.common.bean.Response;
import com.alibaba.fastjson.JSONObject;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/mq")
public class MQController {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Value("${activiti.rocketmq.topic.activiti}")
    private String topic;

    @PostMapping("/send")
    public Response getKey(@RequestBody JSONObject jsonObject) {
        rocketMQTemplate.convertAndSend(String.format("%s:%s", topic, "TAG_ACTIVITI_TASK_REJECT"), jsonObject);
        return Response.success(true);
    }

}

